package easy;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

public class Solution_804 {

    private String[] array = new String[]{".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};

    public int uniqueMorseRepresentations(String[] words) {
        Set<String> set = new HashSet<>();
        for (String word : words) {
            char[] chars = word.toCharArray();
            StringBuffer buffer = new StringBuffer();
            for (char c : chars) {
                buffer.append(array[c-'a']);
            }
            set.add(buffer.toString());
        }
        return set.size();
    }

    public static void main(String[] args) {
        Solution_804 model = new Solution_804();
        System.out.println(model.uniqueMorseRepresentations(new String[]{"gin", "zen", "gig", "msg"}));
    }
}
